home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: dereferencing pointer to incomplete type
- Date: 3 Mar 1996 12:38:59 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4hc3t3$geh@sparcserver.lrz-muenchen.de>
- References: <1996Mar3.040741.27234@dcs.warwick.ac.uk>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero) writes:
-
-
- >Hi everybody.
- >I wonder if anybody can help me to debug the short code below.
- >It is supposed to calculate the area of a polygon, but when I compile
- >it with gcc program.c, it gives me the following errors,
-
- >program.c: In function `calc_area':
- >program.c:22: warning: assignment from incompatible pointer type
- >program.c:24: dereferencing pointer to incomplete type
- >program.c:24: dereferencing pointer to incomplete type
- >program.c:26: warning: assignment from incompatible pointer type
-
- >which I don't understand at all.
-
- >I would appreciate very much any sort of help.
-
- >------------------
-
- >struct polygon
- >{
- > int tried;
- > double x, y;
- > int dir, numtimes, conv;
- > struct polyg *next;
- ^^^^^^^^^^^^^^^ What is a "struct ployg"? A compiler cannot make the
- "obvious" connection between "struct polygon" and "struct polyg", so
- "next" is a pointer to an incolmplete type, i.e. to a struct that
- will be defined somewhere else in your program.
- >};
-
- [unrelated code edited]
-
- >void calc_area(struct polygon* polyg, double* area) {
-
- Calling the parameter polyg will _not_ help to introduce a connection
- between the variable "polyg" and the incomplete type "struct polyg".
-
- >struct polygon* p;
- >double result;
- >p = polyg->next;
-
- Now you try to assign a pointer to an incomplete type to a pointer to
- a "struct polygon".
-
- Hint: Sometimes it is useful to check your spelling if you get a
- "strange" diagnostic.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-